const log4js = require('log4js');
const path = require("path");
const env = process.env.NODE_ENV || "development";
let log4jsConfig;
switch (env) {
    case "development":
    {
        log4jsConfig = path.join(__dirname, '../config/log4js/log4j_configuration_development.json');
        break;
    }
    case "test":
    {
        log4jsConfig = path.join(__dirname, '../config/log4js/log4j_configuration_test.json');
        break;
    }
    case "production":
    {
        log4jsConfig = path.join(__dirname, '../config/log4js/log4j_configuration_production.json');
        break;
    }
    default :
        throw ({message: "没有对应的配置文件"})
}

log4js.configure(log4jsConfig, {reloadSecs: 60});
module.exports.log4js = log4js;
module.exports.Logger = function (name) {
    return log4js.getLogger(name);
};